import axios from '@/api/fetch';
import SERVER from '@/api/server';

// 获取车系 - 销售模块提供的新接口
export const getAllSeries = params => axios.get(`${SERVER.DMSCLOUD_SYSBASEDATA}/vehicleProduct/seriess/all`, { params });

// 获取维修套餐列表
// export const getRepairPackageList = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/group/findGroupItem`, { params });
// 查询维修组合主表
export const findGroupItem = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/group/findGroupItem`, { params });
// 维修类型下拉框
export const getRepairTypes = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedataRepairtypes/findAllRepairType`, { params });

// 下发
export const repairPackageDistribute = params => axios.post(`${SERVER.DMSCLOUD_REPAIR}/repair/group/downAssemble`, params);
// 模板导出
export const exportRepairItemPackage = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/group/exportRepairItemPackage`, { params, responseType: 'blob' });
// 导入数据
export const importRepairItemPackage = params => axios.post(`${SERVER.DMSCLOUD_REPAIR}/repair/group/importRepairItemPackage`, params);

// 查询维修项目
export const findRepairProject = (PACKAGE_TYPE_CODE, PACKAGE_TYPE_NAME, params) =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/group/findRepairProject/${PACKAGE_TYPE_CODE}/${PACKAGE_TYPE_NAME}`, {
    params
  });
// 查询维修备件
export const findRepairPart = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/group/findRepairPart2`, {
    params
  });
// 查询变更履历
export const getAllAssembleHis = params => axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/group/getAllAssembleHis`, { params });

// 查询维修组合项目的维修备件
export const findGroupProjectPart = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/group/findGroupProjectPart`, {
    params
  });

// 查询维修组合品牌車型車繫
export const findAssembleBSM = (packageCode, packageName) => axios.get(`${SERVER.DMSCLOUD_REPAIR}/findAssembleBSM/${packageCode}/${packageName}`, {});
// 查询维修组合代码-下拉框
export const findRepairPackageCode = () => axios.get(`${SERVER.DMSCLOUD_REPAIR}/findRepairPackageCode`, {});
// 保存按钮
export const btnSave = params => axios.post(`${SERVER.DMSCLOUD_REPAIR}/repair/group/btnSave`, params);
// 复制按钮
export const copyPackage = params => axios.post(`${SERVER.DMSCLOUD_REPAIR}/copyPackage`, params);
// 组合明细确定按钮
export const deletePackage = params => axios.post(`${SERVER.DMSCLOUD_REPAIR}/deletePackage`, params);
// 品牌 - 下拉框
export const getPinpSelect = params =>
  axios.get(`/api/basedata/vehicleProduct/brandsqueryall`, {
    params
  });
// 车系 - 下拉框(根据品牌的id)
export const getChexSelect = (brandId, params) =>
  axios.get(`/api/basedata/vehicleProduct/brandsdict/${brandId}/seriessdict`, {
    params
  });
// 车型 - 下拉框()
export const getCheModelSelect = (brandsid, seriessid, params) =>
  axios.get(`/api/basedata/vehicleProduct/brandsdict/${brandsid}/seriessdict/${seriessid}/modelsdict`, {
    params
  });
export const getModels = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/group/getModels`, {
    params
  });
// 查询维修项目的备件信息
export const selectRepairProjectPart = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/group/findProjectPart`, {
    params
  });
// 获取库存备件信息
export const getpartStocksList = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/group/findAllPart`, {
    params
  });
// 获取未被使用的库位
export const getPosition = params =>
  axios.get(`${SERVER.DMSCLOUD_PART}/stockmanage/partmanage/queryLocations/`, {
    params
  });
// 获取所有维修项目
export const findAllProject = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/group/findAllProject`, {
    params
  });
// 获取工单信息
export const findRepairOrderList = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/group/findRepairOrder`, {
    params
  });
// 获取工单的维修项目信息
export const findRepairOrderProject = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/group/findRepairOrderProject`, {
    params
  });
// 获取工单维修项目的备件信息
export const findRepairOrderProjectPart = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/group/findRepairOrderProjectPart`, {
    params
  });
// 删除维修组合
export const delteRepairGroupProject = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/group/delteRepairGroupProject`, {
    params
  });
// 查询全部车系
export const getVehicleSeries = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/baseData/basicData/series`, {
    params
  });
// 根据车系查询车型
export const getVehicleModel = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/baseData/basicData/selectmodel`, {
    params
  });
// 查询所有人
export const getDealerUser = params => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/users/getDealerUser`);

// 查询所有人
export const getAllUser = params => axios.get(`${SERVER.DMSCLOUD_BASEDATA}/basedata/users/getDealerUser`);
// 仓库 -下拉框
export const getStroageList = params =>
  axios.get(`${SERVER.DMSCLOUD_PART}/basedata/partStocks/findUserControlStorageCode`, {
    params
  });
// 导出
export const exportGroupItem = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/group/export/excel`, {
    params,
    responseType: 'arraybuffer'
  });
//  导入模板
export const repairCombload = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/repair/group/repairCombDownload`, {
    params,
    responseType: 'arraybuffer'
  });

// 经销商多级授权导入模板路径
export const repairAbleDownload = params =>
  axios.get(`${SERVER.DMSCLOUD_REPAIR}/basedata/repairParam/exportRepairAbleDownload`, {
    params,
    responseType: 'arraybuffer'
  });

// 经销商多级授权导入模板路径
export const repairFindPart = params =>
  axios.get(`${SERVER.DMSCLOUD_PART}/basedata/partStocks/repairFindPart`, {
    params
  });
//套餐主信息查询
export const queryActivityAll = params => axios.get(`${SERVER.DMSCLOUD_ACTIVITY}/activity/queryActivityAll`, { params });
//套餐执行情况查询
export const queryActivityResult = params => axios.get(`${SERVER.DMSCLOUD_ACTIVITY}/activity/queryActivityResult`, { params });


//套餐明细
export const queryActivityDetail = params => axios.get(`${SERVER.DMSCLOUD_ACTIVITY}/activity/queryActivityDetail`, { params });
/*套餐下发*/
export const releaseActivity = params => axios.get(`${SERVER.DMSCLOUD_ACTIVITY}/activity/releaseActivity`, { params });
/*作废 */
export const changeStatus = params => axios.get(`${SERVER.DMSCLOUD_ACTIVITY}/activity/invalidDown/${params.activityCode}`, { params });
export const getBrandAll = () => axios.post(`${SERVER.DMSCLOUD_ACTIVITY}/activity/getBrandAll`);
export const getSeriesAll = params => axios.post(`${SERVER.DMSCLOUD_ACTIVITY}/activity/getSeriesAll`, { params });
export const getModelAll = params => axios.post(`${SERVER.DMSCLOUD_ACTIVITY}/activity/getModelAll`, { params });

// 套餐保存
export const saveActivity = params => axios.post(`${SERVER.DMSCLOUD_ACTIVITY}/activity/saveActivity`, params);

// 套餐保存
export const updateActivity = params => axios.post(`${SERVER.DMSCLOUD_ACTIVITY}/activity/updateActivity`, params);

//模板下载
export const downCarTem = params => {
  return axios({
    url: `${SERVER.DMSCLOUD_ACTIVITY}/activity/downCarTem`,
    method: 'get',
    responseType: 'blob'
  });
};

export const uploadCarTem = params => {
  return axios({
    url: `${SERVER.DMSCLOUD_ACTIVITY}/activity/uploadCarTem`,
    method: 'get',
    // params:params,
    responseType: 'blob'
  });
};

//套餐导出
export const exportActivity = params => axios.get(`${SERVER.DMSCLOUD_ACTIVITY}/activity/exportActivity`, params, {
  responseType: 'blob'
});

//套餐导出
export const ActivityForExport = params => axios.post(`${SERVER.DMSCLOUD_ACTIVITY}/activity/ActivityForExport`, params, {
  responseType: 'blob'
});


//套餐执行导出
export const ActivityResultForExport = params => axios.post(`${SERVER.DMSCLOUD_ACTIVITY}/activity/ActivityResultForExport`, params, {
  responseType: 'blob'
});

// 生成套餐代码
export const getActivityCode = params => axios.get(`${SERVER.DMSCLOUD_ACTIVITY}/activity/getActivityCode`, { params });


//套餐次数信息查询
export const queryActivityCountAll = params => axios.get(`${SERVER.DMSCLOUD_ACTIVITY}/activity/queryActivityCountAll`, { params });

export const deleteActivityCount = params => axios.get(`${SERVER.DMSCLOUD_ACTIVITY}/activity/deleteActivityCount`, { params });

export const downActivityCount = params => {
  return axios({
    url: `${SERVER.DMSCLOUD_ACTIVITY}/activity/downActivityCount`,
    method: 'get',
    responseType: 'blob'
  });
};


export const importActivityCountsItem = params => {
  return axios({
    url: `${SERVER.DMSCLOUD_ACTIVITY}/activity/importActivityCountsItem`,
    method: 'post',
    // params:params,
    responseType: 'blob'
  });
};
